<template>
  <div>
    <!-- 柱状图 -->
    <div id="bar" style="width: 500px; height: 400px"></div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      chart: null,
      xDataArr: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
      yDataArr: [5, 20, 36, 10, 10, 20],
    };
  },
  methods: {
    barChart() {
      var myChart = this.$echarts.init(document.getElementById("bar"));
      console.log(myChart);
      myChart.setOption({
        xAxis: {
          type: "category",
          data: this.xDataArr,
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: this.yDataArr,
            type: "bar",
            showBackground: true,
            backgroundStyle: {
              color: "rgba(180, 180, 180, 0.2)",
            },
          },
        ],
      });
    },
  },
  mounted() {
    this.barChart();
  },
};
</script>

<style lang="scss" scoped>
</style>